import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:love_app/pages/app/has_lover.dart';
import 'package:love_app/pages/app/route_null.dart';
import 'package:love_app/pages/app/test_center.dart';
import 'package:love_app/pages/app_page.dart';
import 'package:love_app/pages/bottom_appbar/bottom_appbar.dart';
import 'package:love_app/pages/bottom_appbar/new_bottom_appbar.dart';
import 'package:love_app/pages/chat_page/chat.dart';
import 'package:love_app/pages/community/common_ui/commuinty_show_image_ui.dart';
import 'package:love_app/pages/community/details_page.dart';
import 'package:love_app/pages/login_register/forget_password.dart';
import 'package:love_app/pages/login_register/login_page.dart';
import 'package:love_app/pages/login_register/register_page.dart';
import 'package:love_app/pages/love_more/love_alarm.dart';
import 'package:love_app/pages/love_more/love_yima.dart';
import 'package:love_app/pages/love_record/details_item.dart';
import 'package:love_app/pages/love_record/love_gallery.dart';
import 'package:love_app/pages/love_record/love_record.dart';
import 'package:love_app/pages/love_record/love_record_ui/show_image.dart';
import 'package:love_app/pages/love_record/published.dart';
import 'package:love_app/pages/mine/diamond_recharge.dart';
import 'package:love_app/pages/mine/setting_info.dart';
import 'package:love_app/pages/mine/wallet.dart';
import 'package:love_app/pages/mine/we_info.dart';
import 'package:love_app/pages/user_center/user_center.dart';
import 'package:love_app/routes/fluro_convert_util.dart';
import 'package:love_app/test/app_test.dart';
import 'package:love_app/test/bug_test.dart';

class RouteHandlers {
  // 发表恋人动态handler
  static Handler addLoveDynamicHandler = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    String apiPath = params['apiPath']?.first;
    String appBarTitle =
        FluroConvertUtils.fluroCnParamsDecode(params['appBarTitle']?.first);
    return AddPublished(
      apiPath: apiPath,
      appBarTitel: appBarTitle,
    );
  });

  // 恋爱记录
  static Handler loveRecord = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoveRecord();
  });

  // 展示每个item下的所有图片
  static Handler loveRecordShowImage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int itemId = FluroConvertUtils.string2int(params['itemId']?.first);
    int index = FluroConvertUtils.string2int(params['index']?.first);
    return ShowImageUI(
      itemId: itemId,
      index: index,
    );
  });

  // 恋爱记录详情
  static Handler detailsItem = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int itemID = FluroConvertUtils.string2int(params['itemID']?.first);
    return DetailsItem(
      itemID: itemID,
    );
  });

  // 恋爱相册
  static Handler loveGralley = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoveGallery();
  });

  // 点击恋爱相册的图片
  static Handler showGralley = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int index = FluroConvertUtils.string2int(params['index']?.first);
    return ShowGralleyAll(
      index: index,
    );
  });

  // 社区页面的查看高清图片
  static Handler communityShowImageUI = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int index = FluroConvertUtils.string2int(params['index']?.first);
    int itemId = FluroConvertUtils.string2int(params['itemId']?.first);
    String prividerType = params['prividerType']?.first;
    return CommunityShowImageUI(
      index: index,
      itemId: itemId,
      prividerType: prividerType,
    );
  });
  
  // 社区文章详情页
  static Handler detailsPage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int itemId = FluroConvertUtils.string2int(params['itemId']?.first);
    String providerType = params['providerType']?.first;
    return DetailsPage(
      itemId: itemId,
      providerType: providerType,
    );
  });

   // 恋爱记录
  static Handler appIndexPage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return AppPage();
  });

   // 登录页面
  static Handler loginPage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoginPage();
  });

  // 用于bugTest
  static Handler bugTest = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return BugTest();
  });

  // 新的底部导航栏
  static Handler newBottomBar = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return NewBottomAppbar();
  });
  // 不规则底部导航栏
  static Handler oldBottomBar = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MyBottomAppbar();
  });

  // 小游戏
  static Handler loveTree = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return PageBuildImg();
  });

  // 打卡记录
  static Handler loveCard = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return PageBuildImg();
  });

  // 恋爱记录
  static Handler loveRegister = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoveRecord();
  });

  // 悄悄话
  static Handler loveMessage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return PageBuildImg();
  });
  
  // 我的钱包
  static Handler myWallet = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return MyWallet();
  });
  // 我的钱包
  static Handler testCenter = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return TestCenter();
  });
  // 我的钱包
  static Handler diamondRecharge = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return DiamondRecharge();
  });
  // 注册页面
  static Handler registerPage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return Register();
  });
  // 注册页面
  static Handler appTest = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return AppTest();
  });
  // 悄悄话
  static Handler chatPage = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ChatPage();
  });
  // 情侣闹钟
  static Handler loveAlarm = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoveAlarm();
  });
  // 用于拦截没有绑定另一半
  static Handler hasLover = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return HasLover();
  });
  // 姨妈助手
  static Handler loveYima = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return LoveYima();
  });
  static Handler weInfo = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return WeInfo();
  });
  static Handler settingMyName = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return SettingMyName();
  });
  static Handler forgetPassword = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    return ForgetPassWord();
  });
  // // 社区搜索
  // static Handler communitySearch = Handler(
  //     handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  //   return CommunitySearch();
  // });
  // 个人简介页面
  static Handler userCenter = Handler(
      handlerFunc: (BuildContext context, Map<String, List<String>> params) {
    int userId = FluroConvertUtils.string2int(params['userId']?.first);
    return UserCenter(
      userId: userId,
    );
  });
}
